<template>
    <div class="login">
        <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form">
            <h3 class="title">后台管理系统</h3>

            <el-form-item prop="username">
                <el-input
                        prefix-icon="el-icon-user"
                        v-model="loginForm.username"
                        type="text"
                        auto-complete="off"
                        placeholder="账号">
                </el-input>
            </el-form-item>

            <el-form-item prop="password">
                <el-input
                        prefix-icon="el-icon-lock"
                        v-model="loginForm.password"
                        type="password"
                        auto-complete="off"
                        placeholder="密码"
                        @keyup.enter.native="handleLogin">
                </el-input>
            </el-form-item>

            <el-form-item prop="code">
                <el-input
                        class="login-code-input"
                        v-model="loginForm.code"
                        auto-complete="off"
                        placeholder="验证码"
                        style="width: 63%;float: left"
                        @keyup.enter.native="handleLogin">
                </el-input>
                <div class="login-code">
                    <img :src="codeUrl" @click="getCode"/>
                </div>
            </el-form-item>

            <el-form-item style="margin: -10px auto;">
                <el-checkbox v-model="loginForm.rememberMe" style="float: left;">
                    记住密码
                </el-checkbox>
            </el-form-item>

            <el-form-item>
                <el-button
                        :loading="loading"
                        size="medium"
                        type="primary"
                        style="width:100%;"
                        @click.native.prevent="handleLogin">
                    <span v-if="!loading">登 录</span>
                    <span v-else>登 录 中...</span>
                </el-button>
            </el-form-item>
        </el-form>

        <div class="el-login-footer">
            <span>Copyright © 2019-2020 yangjun All Rights Reserved.</span>
        </div>
    </div>
</template>

<!--http://vue.ruoyi.vip/login?redirect=%2Fuser%2Fprofile-->
<script>
	export default {
		name: "Login",
		data() {
			return {
				codeUrl: "/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAAkAG8DASIAAhEBAxEB/8QAHwAAAQUBAQEBAQ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xVSTQURt9jd3NrICGx5jOhPAyVJ54GOopykpO5MYuKsWknEUz5YNGW5wSShxnBHY4IOPfNZ3iuZG0g2SfPc3LqsUa8kkMDn9KbfRas0Qgu1aeDgmbT28qUEdypJzk44B459qh0NdNt5TNau99JOQUnYguFztPUjA4J9Tg4zwKULfEErv3TWtrU2NlDBI5kRVVS3UoQAMj0HH4dfWpGaVz5KyhJ1GQ3UMvr0xn/PerEjlXjUBCHbDFmxgYPTjk5xxxxk9sGpNZwJvym1HbeXjHzBsAdh0wAPwA9KlPUrl0sQavqk9hKyRLGQLC5ufnBPzR+XtHXp85z+FaGxpIsLK8ZEmdy4JIDZI+YHg4x9DxjjBRUx+NIp7f15nI654j1C1FmtsYoTPbR3DsqZJY5BHORjge/HWtnSdHtnjt9Uut95fSRhxNcYYxhsNtUYAUA9OM+9FFbyVou3cXVm3RRRWAgooooAKKKKACqN3pFndzee0flz/wDPaM7WPTr68DHPTtiiimtwObOr3dn4gFgCksM86oxdAGHzbM5XBJwByc9BXU2QUJKAoBEhUt3bAABY9zgDn2ooqppEx6n/2Q==",
				cookiePassword: "",
				loginForm: {
					username: "",
					password: "admin123",
					rememberMe: false,
					code: "",
					uuid: ""
				},
				loginRules: {
					username: [
						{required: true, trigger: "blur", message: "用户名不能为空"}
					],
					password: [
						{required: true, trigger: "blur", message: "密码不能为空"}
					],
					code: [{required: true, trigger: "change", message: "验证码不能为空"}]
				},
				loading: false,
			}
		},
		created() {
			this.getCode();
			this.getCookie();
		},
		methods: {
			getCode() {
				this.codeUrl = "data:image/gif;base64," + this.codeUrl;
				this.loginForm.uuid = '4130a834810448ef9010eb4c0bf1b161';
			},
			getCookie() {

			},
			handleLogin() {
				this.$router.push('/');
			}
		}
	}
</script>

<style rel="stylesheet/scss" lang="scss">
    .login {
        display: flex;
        justify-content: center;
        align-items: center;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-image: url("../assets/login-background.jpg");
        background-size: cover;
    }

    .login-form {
        border-radius: 6px;
        background: #ffffff;
        width: 400px;
        padding: 25px 25px 5px 25px;
        text-align: center;
        height: 345px;
        .title {
            margin: 0 auto 30px auto;
            text-align: center;
            color: #707070;
        }
        .el-form-item {
            width: 80%;
            text-align: center;
            margin: 20px auto;
        }
    }

    .login-code {
        width: 33%;
        float: right;
        img {
            cursor: pointer;
            vertical-align: middle;
            width: 100%;
        }
    }

    .el-login-footer {
        height: 40px;
        line-height: 40px;
        position: fixed;
        bottom: 0;
        width: 100%;
        text-align: center;
        color: #fff;
        font-size: 12px;
        letter-spacing: 1px;
    }
</style>